<template>
    <div id="app">
      <form action="" @submit.prevent="addBook">
        <table border="1" align="center">
          <tr>
            <td>书名</td>
            <td><input type="text" v-model="b.name"/></td>
          </tr>
          <tr>
            <td>作者</td>
            <td><input type="text" v-model="b.author"/></td>
          </tr>
          <tr>
            <td>价格</td>
            <td><input type="text" v-model="b.price"/></td>
          </tr>
          <tr>
            <td colspan="2">
              <input type="submit" value="添加"/>
            </td>
          </tr>
        </table>
      </form>
    </div>
</template>

<script>
  export default {
      name: "BookAdd",
          data() {
            return {
               b: {}
          }
      },
      methods:{
          addBook(){
              this.axios.post("/books",this.b)
                .then((resp)=>{
                    this.$router.push("/");
              });
         }
     }
  }
</script>

<style scoped>

</style>
